package com.xbongbong.saas.model;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.domain.entity.UpdateDataEntity;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.saas.domain.entity.AssembleProductEntity;
import com.xbongbong.saas.domain.entity.ProductBaseInfoEntity;
import com.xbongbong.saas.domain.entity.ext.AssembleEntityExt;
import com.xbongbong.saas.enums.UpdateDataTypeEnum;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * 装配出入库单
 * @author 吴峰
 * @version v1.0
 * @date 2019/2/18 15:08
 * @since v1.0
 */
public interface AssembleModel extends IModel<AssembleEntityExt> {
    /**
     * 查询单个实体
     * @param key 数据id
     * @param corpid 公司id
     * @return 实体
     */
    AssembleEntityExt getByKey(Long key, String corpid);

    /**
     * 删除实体
     * @param idList 数据
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer deleteBatch(List<Long> idList, String corpid) throws XbbException;


    /**
     * 单个删除
     * @param id
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer deleteByKey(Long id,String corpid) throws XbbException;

    /**
     * 批量编辑
     * @author 吴峰
     * @date 2019/3/20 14:37
     * @param updateDataList
     * @param corpid 公司id
     * @return java.lang.Integer
     * @throws XbbException 业务异常
     */
    Integer updateBatch(List<UpdateDataEntity> updateDataList, String corpid) throws XbbException;

    /**
     * 批量更新团队
     *
     * @param dataIdList
     * @param corpid
     * @param userId
     * @throws
     * @author long.rao
     * @date 2020-04-10 10:53
     */
    Integer batchUpdateOwner(List<Long> dataIdList, String corpid, String userId, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * 批量更新
     * @param updateList
     * @param corpid 公司id
     * @param refreshPolicy
     * @return
     * @throws XbbException
     */
    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    List findEntitysWithoutSub(Map<String, Object> param);

    /**
     * 编辑时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     */
    void formatUpdateExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 装配单编辑格式化数据格式
     *
     * @param saasAnalysisDataDTO saas编辑数据
     * @throws XbbException 参数格式错误异常
     * @param result 要返回的jsonobject
     * @author Jian.Wang
     * @date 2019/1/23 20:00
     * @since v1.0
     * @throws XbbException 异常
     **/
    void formatData(SaasAnalysisDataDTO saasAnalysisDataDTO, JSONObject result) throws XbbException;

    void formatProduct4Show2(Long dataId, String corpid, JSONObject data, Boolean forProcess, Integer operate, UpdateDataTypeEnum updateDataTypeEnum) throws XbbException;

    JSONObject formatSingleProduct(AssembleProductEntity entity, ProductBaseInfoEntity productBaseInfoEntity);
}
